// 使用jsonwebtoken 生成token
const jwt = require('jsonwebtoken');

const secret = 'zylwin_123';
module.exports = {
	encrypt: (data, expiresIn = '1d') => {
		return jwt.sign(data, secret, { expiresIn });
	},

	decrypt: (token) => {
		try {
			return jwt.verify(token, secret);
		} catch (error) {
			if (error) {
				return false;
			}
		}
	}
};
